<template>
  <div id="app">
  <ul>
    <li v-for='(item) in list' :key='item.id'>{{item.num}}  <button @click = 'del(item.id)'>删除</button></li>
  </ul>
  <button @click='create'>生成</button>
  </div>
</template>

<script>


export default {
  name: 'App',
  data(){
    return{
     list:
      []  
    }
  },
   methods:{
       create(){
          let  num = parseInt(Math.random() * 20) 
          this.list.push({
           id:  +new Date(),
           num:  num
          })
           },
           del(id){
           this.list = this.list.filter(item => item.id !== id)
           }         
       }
   }

</script>

<style>

</style>
